
import java.util.*;
public class StringFormat
{
    public String formatString(String A, int n, char[] arg, int m)
    {
        StringBuffer ret = new StringBuffer(); char[] s = A.toCharArray();
        int j = 0;
        for(int i = 0; i < n; i++)
        {
            if(s[i] != '%')
            {
                ret.append(s[i]);
            }
            else
            {
                if(i + 1 < n && s[i + 1] == 's')
                {
                    ret.append(arg[j++]); i++;
                }
                else
                {
                    ret.append(s[i]);
                }
            }
        }
        while(j < m)
        {
            ret.append(arg[j++]);
        }
        return ret.toString();
    }
}

